﻿@page "/selectbar"

<RadzenExample Name="SelectBar">
<div class="row">
    <div class="col-md-6">
        <h3>SelectBar with single selection</h3>
        <RadzenSelectBar @bind-Value="value" TValue="int" Change="@((args) => Change(args, "SelectBar with single selection"))" Style="margin-bottom: 20px;">
            <Items>
                <RadzenSelectBarItem Text="Orders" Value="1" />
                <RadzenSelectBarItem Text="Employees" Value="2" />
                <RadzenSelectBarItem Text="Customers" Value="3" />
            </Items>
        </RadzenSelectBar>
        <br />
        <h3>SelectBar with multiple selection</h3>
        <RadzenSelectBar @bind-Value="values" TValue="int" Multiple="true" Change="@((args) => Change(args, "SelectBar with multiple selection"))" Style="margin-bottom: 20px;">
            <Items>
                <RadzenSelectBarItem Text="Orders" Value="1" />
                <RadzenSelectBarItem Text="Employees" Value="2" />
                <RadzenSelectBarItem Text="Customers" Value="3" />
            </Items>
        </RadzenSelectBar>
        <br />
        <h3>Disabled SelectBar with multiple selection</h3>
        <RadzenSelectBar Disabled="true" @bind-Value="values" TValue="int" Multiple="true" Change="@((args) => Change(args, "Disabled SelectBar with multiple selection"))">
            <Items>
                <RadzenSelectBarItem Text="Orders" Value="1" />
                <RadzenSelectBarItem Text="Employees" Value="2" />
                <RadzenSelectBarItem Text="Customers" Value="3" />
            </Items>
        </RadzenSelectBar>
        <br Style="margin-bottom: 20px;" />
    </div>
    <div class="col-md-6">
        <h3>Events</h3>
        <RadzenCard style="overflow: auto;height:500px;">
            @foreach (var e in events.OrderByDescending(i => i.Key))
            {
                @e.Value
                <br />
            }
        </RadzenCard>
    </div>
</div>
</RadzenExample>

@code {
    IEnumerable<int> value = new int[] { 1 };
    IEnumerable<int> values = new int[] { 1, 2 };

    Dictionary<DateTime, string> events = new Dictionary<DateTime, string>();

    void Change(IEnumerable<int> value, string name)
    {
        var str = string.Join(", ", value);
        events.Add(DateTime.Now, $"{name} value changed to {str}");
        StateHasChanged();
    }
}
